The present invention relates to a data processing apparatus and, more particularly, to a microcomputer having a sequential pulse producing function in which pulses are produced in sequence at a plurality of output ports.
Microcomputers have been widely applied to use in various systems as a central processing units. The application field of the microcomputer includes, for example, use as a mechanical control in which the open/close control of a valve, the on/off control of a motor and the like are performed by a pulse produced and outputted from the microcomputer. The pulse width of the pulse corresponds to an open (or close) period of the valve or to an on (or off) period of the motor. The microcomputer monitors the current operating conditions of the equipment having the valve, motor or the like to be controlled, and creates in accordance therewith time data corresponding to the pulse width of the pulse to be produced. When the microcomputer receives a pulse request, it produces a pulse at a predetermined output port connected to the valve, motor or the like during the period corresponding to the time data.
Since the pulse request is generated in asynchronism with the data processing operation of the microcomputer and since the pulse to be produced has a variable pulse width, the microcomputer executes the pulse producing function as an interrupt processing operation. More specifically, when the pulse request is generated, the microcomputer suspends the execution of a main program, saves the current contents of a program counter and a program status word register into a data memory, and thereafter loads the leading address of the interrupt program to the program counter. The interrupt program is thereby initiated. In the execution of the interrupt program, the microprocomputer sets the predetermined output port to produce a pulse thereat and stores a down counter with the time data which has been already created by the main program. The down counter is further supplied with a clock pulse signal and counts down the time data by one each time the clock pulse is supplied thereto. After the execution of the interrupt program, the microcomputer restores the saved contents into the program counter and the program status word register. The suspended main program is thereby resumed. During the execution of the main program, the down counter continues to count down the time data and finally produces a borrow signal which is in turn supplied to the microcomputer as an interrupt request signal. In response to this interrupt request signal, the microprocessor suspends again the execution of the main program, saves the current contents of the program counter and program status word register into the data memory, and thereafter loads the leading address of an interrupt program to execute the same. The port, which has been in a set state, is now reset to stop the pulse generation therefrom. The saved contents are thereafter restored into the program counter and program status word register to restart the suspended main program.
Thus, the conventional microcomputer performs the pulse producing function by the execution of the two interrupt programs. In order to initiate an interrupt program, an overhead for saving the contents of the program counter and the program status word register occurs, as mentioned above. Since the overhead requires a relatively long time period, real-time control of the pulse production is not performed. Moreover, as the frequency of the pulse to be produced increases and/or the number of pulses to be produced at different ports increases, frequent saving and restoring of the contents of the program counter and program status word register are frequently required, so that the execution efficiency of the main program is reduced remarkably.